package main

import (
	"fmt"
	"os"
)

func main() {
	file, err := os.OpenFile("F:/go-the-way-of-learning/day3/9file_write/sb.txt", os.O_RDWR, 0644)
	if err != nil {
		fmt.Printf("open file failed, err:%v\n", err)
		return
	}
	defer file.Close()

	file.Seek(1, 0) // 光标移动一位

	var s []byte
	s = []byte{'c'}
	file.Write(s)   // 写入一个值
	var ret [1]byte // 读取一个字节
	read, err2 := file.Read(ret[:])
	if err2 != nil {
		fmt.Printf("read from file failed, err:%v\n", err2)
		return
	}
	fmt.Println(string(ret[:read]))
}
